package LearnAlgorithm.a_eclipseHello;

import java.util.Arrays;

public class test2 {
	public static void main(String[] args) {
		int[] s = new int[] {1,2,3,4};
		int[] t = new int[] {6,6,6,6};
		test1[] arr = new test1[4];
		for (int i = 0; i < s.length; i++) {
			arr[i] = new test1(s[i], t[i]);
		}
		Arrays.sort(arr);
		for (int i = 0; i < arr.length; i++) {
			System.out.println(arr[i]);
		}
	}
	
	private static class test1 implements Comparable<test1> {
		int s;
		int t;
		public test1(int s, int t) {
			this.s = s;
			this.t = t;
		}
		@Override
		public int compareTo(test1 o) {
			int x = this.t - o.t;
			if (x == 0) {
				return this.s - o.s;
			}
			return x;
		}
		@Override
		public String toString() {
			return s + ", " + t + ", sub = " + (t - s);
		}
	}
}
